//
//  DrivingListTableVC.m
//  duoduo
//
//  Created by wanghao on 16/10/12.
//  Copyright © 2016年 LX. All rights reserved.
//

#import "DrivingListTableVC.h"
#import "PoolListCell.h"
#import "DCPicScrollView.h"
#import "DrivingListCell.h"
#import "DrivingInfo_ViewController.h"

@interface DrivingListTableVC ()
{
    //轮播图的数据
    NSArray *cycleImageArr;
    UIView *headerView;
    NSArray * chexingArr;
    NSArray * chepaiArr;
    NSArray * priceArr;
}
@end

@implementation DrivingListTableVC

- (void)viewDidLoad {
    [super viewDidLoad];

    cycleImageArr = @[@"banner1@2x",@"banner1@2x",@"banner1@2x"];
    chexingArr = @[@"银白色宝马525LI",@"黑色宝马X1",@"黑色奥迪A4L",@"白色众泰T600",@"白色特斯拉"];
    chepaiArr = @[@"粤B·BO966",@"粤B·8A966",@"粤B·8C076",@"粤B·9PA66",@"粤B·8A965"];
    priceArr = @[@"¥ 88/人",@"¥ 38/人",@"¥ 108/人",@"¥ 35/人",@"¥ 128/人"];
    [self initUI];

}

//初始化TableView
- (void)initUI
{
    self.tableView.tableFooterView.backgroundColor = LXHexColor(0xD6D6D6);

    [self.tableView registerNib:[UINib nibWithNibName:@"DrivingListCell" bundle:nil] forCellReuseIdentifier:@"listcell"];
    self.tableView.tableFooterView = [[UIView alloc]init];
    headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 150)];
    [self getTableHeaderView:cycleImageArr];
}

#pragma mark- TableViewHead
-(void)getTableHeaderView:(NSArray *)arr
{
    DCPicScrollView  *picView = [DCPicScrollView picScrollViewWithFrame:CGRectMake(0, 0, ScreenWidth, 150) WithImageUrls:arr];
    [headerView addSubview:picView];
    self.tableView.tableHeaderView = headerView;

}
#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
#warning Incomplete implementation, return the number of sections
    return chexingArr.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
#warning Incomplete implementation, return the number of rows
    return 1;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    DrivingListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"listcell" forIndexPath:indexPath];

    cell.chexingLabel.text = chexingArr[indexPath.section];
    cell.chepaiLabel.text = chepaiArr[indexPath.section];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 80;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    DrivingInfo_ViewController * vc = [[DrivingInfo_ViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        return 30;
    }
    return 15;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 40)];
        view.backgroundColor = LXHexColor(0xF5F6F7);
        UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(15, 10, 80, 18)];
        label.textColor = [UIColor grayColor];
        label.text = @"附近车辆";
        label.font = [UIFont systemFontOfSize:16];
        [view addSubview:label];
        return view;
    }
    return nil;
}

@end
